
<template>
    <Modal
            fullscreen
            v-model="modal1"
            title="login"
            @on-ok="cancel"
            @on-cancel="cancel">
        <p slot="header" style="color:#f60;text-align:center">

        </p>
        <p slot="footer" style="color:#f60;text-align:center">

        </p>
        <div style="width: 400px;border: solid 1px #CCC;padding:20px;border-radius: 15px;margin: 20px auto;">
            <Form ref="formInline" :model="formInline" >
                <FormItem>
                    <h1 style="text-align:center">请登录</h1>
                </FormItem>
                <FormItem prop="user">
                    <Input type="text" v-model="formInline.user_name" placeholder="用户名">
                    <Icon type="ios-person-outline" slot="prepend"></Icon>
                    </Input>
                </FormItem>
                <FormItem prop="password">
                    <Input type="password" v-model="formInline.password" placeholder="密码">
                    <Icon type="ios-information-circle" slot="prepend"></Icon>
                    </Input>
                </FormItem>
                <FormItem>
                    <Button type="primary" @click="login">登录</Button>
                </FormItem>
            </Form>
        </div>

    </Modal>
</template>
<script>
    export default {
        data () {
            return {
                modal1: true,
                formInline: {
                    user_name: '',
                    password: ''
                },
            }
        },
        mounted(){
            let $this = this;
          this.$api.admin_user({},function(data){
              if(data.code == 0){
                  location.href="#/";
                  location.reload();
              }
          });
        },
        methods: {
            login(){
                let $this = this;
                this.$api.login(this.formInline,function(resp){
                    $this.$Message.info(resp.msg);
                    setTimeout(function(){
                        location.reload();
                    },1000*2)
                });
            },
            cancel () {
                location.reload();
            }
        }
    }
</script>